package io.itit.ecp.admin.common.enums;

import io.itit.grass.common.enums.IBaseEnum;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * <p>
 *
 * @Author：Roy
 * @Description：数据范围
 * @Date：Create by 2024-01-17 16:55:06
 */
public interface IDataRangeEnums {

    /* 范围级别(all:全部,project:按项目,edifice:按楼栋,floor:按楼层,room:按空间,company:按公司) */
    enum RangeLevel implements IBaseEnum {
        rangeLevelAll("all", 1, "", "", "全部"),
        rangeLevelProject("project", 2, "ecp_tt_scene_project", "scene_project_id", "按项目"),
        rangeLevelEdifice("edifice", 3, "ecp_tt_scene_edifice", "scene_edifice_id", "按楼栋"),
        rangeLevelFloor("floor", 4, "ecp_tt_scene_floor", "scene_floor_id", "按楼层"),
        rangeLevelRoom("room", 5, "ecp_tt_scene_room", "scene_room_id", "按空间"),
        rangeLevelCompany("company", 6, "ecp_tt_scene_company", "scene_company_id", "按公司");

        public final String rangeLevel;
        public final int level;
        public final String table;
        public final String column;
        public final String desc;

        RangeLevel(String rangeLevel, int level, String table, String column, String desc) {
            this.rangeLevel = rangeLevel;
            this.level = level;
            this.table = table;
            this.column = column;
            this.desc = desc;
        }

        @Override
        public Serializable getValue() {
            return rangeLevel;
        }

        @Override
        public String getDesc() {
            return desc;
        }

        public static RangeLevel containsRangeLevel(String rangeLevel) {
            if (StringUtils.isEmpty(rangeLevel)) {
                return null;
            }
            for (RangeLevel rl : RangeLevel.values()) {
                if (rl.rangeLevel.equals(rangeLevel)) {
                    return rl;
                }
            }
            return null;
        }

        public static int getLevel(String rangeLevel) {
            RangeLevel rl = containsRangeLevel(rangeLevel);
            return rl == null ? 99 : rl.level;
        }
    }

    /* 状态(1:启用,2:禁用) */
    enum Status implements IBaseEnum {
        status1("1", "启用"),
        status2("2", "禁用");

        public final String status;
        public final String desc;

        Status(String status, String desc) {
            this.status = status;
            this.desc = desc;
        }

        @Override
        public Serializable getValue() {
            return status;
        }

        @Override
        public String getDesc() {
            return desc;
        }
    }

}